#pragma once

#include <vector>

#include "object3D.h"
#include "point3D.h"
#include <vector>
#include <math.h>

class Curve
{
public:

	enum Plane
	{
		XY,
		XZ,
		YZ
	};

	enum Type
	{
		BEZIER = 0,
		BSPLINE,
		NORMAL
	};

public:
	Curve(Plane plane,Type type,int numberPoints);
	~Curve();

	void Render();

	void Update(float dt);

	void AddControlPoint(Point3D point);

	void AddPoint(Point3D point);

	void ShowControlPoints(bool show);

	void ShowCurveControl(bool show);

	void DeleteAllControlPoints();

	const std::vector<Point3D*>& GetCurvePoints()const;

	static Point3D CubicBezierPoint(float u,const Point3D* controlPoints[]);

	static Point3D CubicBSplinePoint(float u,const Point3D* controlPoints[]);

	void Close();
	
private:

	void calculateCurvePoints();
	
	Plane m_plane;
	Type m_type;

	int m_numberPoints;

	bool m_showControlPoints;
	bool m_showCurveControl;

	ListPoints3D m_controlPoints;

	ListPoints3D m_curvePoints;

private: // configuration

	static float COLOUR_CONTROL_POINTS[3];
	static float COLOUR_CURVE_CONTROL[3];
	static float COLOUR_CURVE[3];

	static const float LINE_WIDTH;
	static const float POINT_SIZE;
	
};

